/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package worms;

import gameengine.*;
import java.awt.Point;

/**
 * Classe que representa os espinhos que ficam no chão
 * @author Victor
 */
public class Espinho extends SpriteEstatica implements IUpdateable
{
	private static final Point POSICAO_ESPINHO = new Point(0, 600);

	private GameContainer container;

	public Espinho(GameContainer container)
	{
		super(new Textura("./src/worms/images/espinhos.png"), POSICAO_ESPINHO);
		
		this.container = container;
		container.AddSprite(this);
	}

	/**
	 * Testa colisão com os jogadores e mata eles caso batam nos espinhos
	 * @owner Victor
	 */
	public void Atualizar(float milisegundos)
	{
		for(Object objetoSprite : container.GetAllSprites())
		{
			if (objetoSprite instanceof Player)
			{
				Player player = (Player) objetoSprite;
				if (GetRetanguloColisao().intersects(player.GetRetanguloColisao()))
				{
					player.Morrer();
				}
			}
		}
	}
}
